﻿* Encoding: UTF-8.
TITLE Creating Variables for POQ Paper.

*download the anes_timeseries_2016.sav file from HarvardDataVerse or directly from the ICPSR site.
*Note that this syntax is part of a larger syntax file that a colleague and I use as the basis for several papers, class projects, etc. 
*Thus, this file contains many more variables than the ones needed to replicate the POQ paper. 

*most of the starred comments are not in reference for the POQ paper but other analyses. 


****************************************************************.
****************************************************************.
WEIGHT off.

COMPUTE Year = 2016. 
Formats        Year (F4.0).
VARIABLE LABELS Year "Year".

RENAME VARIABLES (V160102f = WeightFtF) (V160102w = WeightWeb) 
		 (V160102 = WeightFull).
*DESCRIPTIVES   WeightFtF, WeightWeb, WeightFull.
 
RENAME VARIABLES V160501 = Mode.
VALUE LABELS Mode 1"FTF" 2"Web".


RENAME VARIABLES 
                                    (V161342 = Gender) 
		(V161003 = PolInt) 
		(V161004 = CampInt) 
		(V161005 = Voted12) 
		(V161006 = WhoVote12) 
		(V161007 = WebAccess) 
		(V161008 = AnyNews07) 
		(V161009 = AnyNewsNatlP) 
		(V161021 = VotedPrimary16) 
		(V161021a = Prime16Vote) 
		(V161022a = VotedEarly) 
		(V161027 = EarlyVtWho) 
		(V161028 = EarlyVtPrefStrng) 
		(V161030 = PreIntendVt) 
		(V161031 = PreVtPref) 
		(V161032 = PreVtPrefStrng).
EXECUTE. 

*Create Voted16 from Pre Post Summary.
FREQUENCIES V161022 VotedEarly V161026 V162031 V162031x.
RECODE V162031x (1=1)(0= 0)(else = 9) into Voted16. 
MISSING VALUES Voted16 (9).
FREQUENCIES V162031x Voted16.

*940 respondents are missing; Does not change with the following commands.
If 		(Missing(Voted16) and VotedEarly EQ 1) Voted16 = 1. 
If 		(Missing(Voted16) and V161026 EQ 1) Voted16 = 1. 
If 		(Missing(Voted16) and V162031 EQ 4) Voted16 = 1. 
*But if we include people who said they voted early but were not confirmed 
 early voters, we get 8 extra voters (932 missing).
If 		(Missing(Voted16) and V161022 EQ 1) Voted16 = 1. 
Frequencies 	V162031x Voted16.
Formats 	Voted16 (F1.0). 

*Count votes in 2012 and 2016, talking about voting, going to rallies, wear buttons, other work, contributing money.
COUNT CampnBehv = Voted12, VotedPrimary16, Voted16, V162010,  
		      V162011, V162012, V162013,  
		      V162014, V162016, V162017 (1). 

*Count involvement in protest, petition, money to religious org, 
	money to soc/pol org, sent pol message on FB or Twitter.
COUNT OthrPolBehv = V162018a,V162018b,V162018c,V162018d,V162018e,V162019 (1). 



RECODE 		PolInt (1=5)(2=4)(3=3)(4=2)(5=1)(else = 9)/ 
		CampInt (1=5)(2=3)(3=1)(else = 9)/ 
		WebAccess (-1,1 = 1)(-8,2 = 0)/ 
		AnyNews07 (-9 thru -1 = 9)/ 
		AnyNewsNatlP (1=4)(2=3)(3=2)(4=1)(5=0)(else = 9).
 

If 		(AnyNews07 = 0) AnyNewsNatlP = 0.

 
VALUE LABELS 	PolInt 1 "Never" 2 "Some of the Time" 3 "Half the Time" 4 "Most of the Time" 5 "Always"/ 
		CampInt 1 "Not Much Interested" 3 "Somewhat Interested" 5 "Very Interested"/ 
		WebAccess,Voted12 0 "No" 1 "Yes"/ 
		AnyNewsNatlP 0 "None" 1 "A Little" 2 "A Moderate Amount" 3 "A lot" 4 "A Great Deal"/ 
                                    Gender 1"Male" 2"Female". 

VARIABLE LABELS	Voted16 "Voted in the 2016 Federal Electons?"/
		CampnBehv "COUNT of Campaign Behaviors Performed"/
	                  OthrPolBehv "COUNT of Noncampaign Political Behaviors Performed".
EXECUTE. 

*Frequencies        V161126,V161127.
RENAME VARIABLES (V161126 = LibCon). 

RECODE Libcon (-9 thru -1 = 9) (99=9). 

MISSING VALUES 	 Libcon (9). 
Frequencies        Libcon.
if (Missing(Libcon) and V161127 EQ 1) Libcon = 3. 
if (Missing(Libcon) and V161127 EQ 2) Libcon = 5. 
if (Missing(Libcon) and V161127 EQ 3) Libcon = 4. 
Frequencies        Libcon.

*Use any questions that have objective answers; SLIGHTLY REVISED , 7-12-18.
COUNT PolKnow = V161137 (1), V161138a (1), V161147 (1), V161221 (1),
	               V161513 (6), V161514 (1), V161515 (2), V161516 (2), 
                             V162072 (1), V162073a (1), V162074a (1), V162075a (1), V162076a (1), 
                                                 V162073b (1), V162074b (1), V162075b (1), V162076b (1), 
                             V162137 (2), V162191a (2), V162255 (2).  
*NOTE: V162073b, 74b, 75b, 76b, all code "partially correct" as .5; HAVE NOT EXAMINED THIS.
COUNT VocabTest = V161497, V161498, V161499, 
                                V161500, V161501, V161502, 
                                V161503, V161504, V161505, 
	              V161506 (1). 
VARIABLE LABELS  PolKnow "Political Knowledge Scale (# Answers Correct)"/
	                VocabTest "# Vocabulary Questions Answered Correctly".
EXECUTE. 


RECODE	V161138x (1=1)(2=2)(3=3)(4=4)(5=5) into InequalityGap.
VALUE LABELS InequalityGap 1 "Much Larger Now" 3 "About the Same" 5 "Much Smaller Now".

if	(Missing(InequalityGap) and V161137 EQ 1) InequalityGap = 2.
if	(Missing(InequalityGap) and V161137 EQ 2) InequalityGap = 4.


VARIABLE LABELS	InequalityGap "Beliefs About Income Inequality in the U.S.".


RENAME VARIABLES (V161139 = EconNow)(V161140x = RetroEcon)
	                   (V161142x = RetroUnemp).
MISSING VALUES EconNow, RetroEcon, RetroUnemp (9).
if		(Missing(RetroEcon) and V161140 EQ 1) RetroEcon = 2.
if		(Missing(RetroEcon) and V161140 EQ 3) RetroEcon = 4.
if		(Missing(RetroUnemp) and V161142 EQ 1) RetroUnemp = 2.
if		(Missing(RetroUnemp) and V161142 EQ 3) RetroUnemp = 4.
RECODE EconNow, RetroEcon, RetroUnemp (-1, -8,-9 = 9).

RENAME VARIABLES  (V161158x = PartyID).
RECODE PartyID (1=0)(2=1)(3=2)(4=3)(5=4)(6=5)(7=6)(else=9).
VALUE LABELS   PartyID 0 "Strong Democrat" 1 "Weak Democrat" 2 "Lean Democrat"
                        3 "Independent" 4 "Lean Republican" 5 "Weak Republican" 6 "Strong Republican".
VARIABLE LABELS PartyID "Party Identification Scale".
MISSING VALUES  PartyID (9).
FORMATS PartyID (F1.0).
FREQUENCIES PartyID.


RENAME VARIABLES 	(V161128 = LibConHC) 
		(V161129 = LibConDT) 
		(V161130 = LibConDemP) 
		(V161131 = LibConRepP) 
		(V161136 = DividedGov). 

RECODE Libcon, LibconHC, LibconDT, LibconDemP, LibconRepP, DividedGov (-9 thru -1 = 9) (99=9). 



RENAME VARIABLES	(V161178 = GovServ)
			(V161179 = GovServHC)
			(V161180 = GovServDT)
			(V161181 = DefSpend)
			(V161182 = DefSpendHC)
			(V161183 = DefSpendDT)
			(V161184 = NHI)
			(V161185 = NHIHC)
			(V161186 = NHIDT)
			(V161189 = GuarJobs)
			(V161190 = GuarJobsHC)
			(V161191 = GuarJobsDT)
			(V161198 = Aid2Blacks)
			(V161199 = Aid2BlacksHC)
			(V161200 = Aid2BlacksDT)
			(V161201 = EnviJobs)
			(V161202 = EnviJobsHC)
			(V161203 = EnviJobsDT).
RECODE	GovServ to GovServDT (1=7)(2=6)(3=5)(4=4)(5=3)(6=2)(7=1)(else = 9).

VALUE LABELS GovServ to GovServDT  1 "Many More Gov Services" 7 "Many Fewer Services".
RECODE DefSpend to DefSpendDT, NHI to NHIDT, GuarJobs to GuarJobsDT,
                Aid2Blacks to Aid2BlacksDT, EnviJobs to EnviJobsDT (lo thru -1 = 9) (99=9).
MISSING VALUES  GovServ to GovServDT, DefSpend to DefSpendDT,
	              NHI to NHIDT, GuarJobs to GuarJobsDT,
	              Aid2Blacks to Aid2BlacksDT, EnviJobs to EnviJobsDT (9).
EXECUTE.


RENAME VARIABLES (V162181=AbortHC) (V162182=AbortDT) (V161232 = Abortion) (V161233 = DeathPen).
RECODE		Abortion (1=7)(2=5)(3=3)(4=1)(else = 9)/
		AbortHC, AbortDT (1=7)(2=5)(3=3)(4=1)(else = 9)/
		DeathPen (1=5)(2=3)(else = 9).
if		(DeathPen EQ 3 and V161233a EQ 1) DeathPen = 1.
if		(DeathPen EQ 5 and V161233a EQ 1) DeathPen = 7.
VALUE LABELS    Abortion, AbortHC, AbortDT
 	              1 "Always Legal as Matter of Personal Choice" 
	              3 "Legal if Need Clearly Established"
	              5 "Only Legal if Rape,Incest,or Woman's Life Endangered"
                                7 "Never Legal"/
                             DeathPen 1 "Strongly Oppose" 7 "Strongly Favor".
MISSING VALUES  Abortion, AbortHC, AbortDT, DeathPen (9).
FORMATS Abortion, DeathPen (F1.0).


RENAME VARIABLES (V161221 = GlobalWarming) (V161222 = Anthropogenic).
RECODE		GlobalWarming (1=1)(2=5)(else = 9)/
		Anthropogenic (1=1)(2=5)(3=3)(else = 9).
MISSING VALUES GlobalWarming,Anthropogenic (9).
FORMATS GlobalWarming,Anthropogenic (F1.0).
VALUE LABELS     GlobalWarming 1 "Probably happening" 5 "Probably Not Happening"/
	             Anthropogenic 1 "Caused by Man" 5 "Natural Causes".



Frequencies	V161308x,V161267,V161267c,V161267x.

Rename Variables (V161267 = Age) (V161308x = SubjSocClass) (V163001a = State).
Recode        	Age (-8, -9 = 99).


Rename Variables (V161270 = EducYrs) (V161309 = Hispanic)
		 (V161310x = RaceEth) (V161361x = FamIncome) .


Missing Values	Age (99), Hispanic, RaceEth,  FamIncome (-9 thru -1).

Recode 		EducYrs (1=1) (2=3) (3=6) (4=8) (5=9) (6=10) (7,8=11) 
                	 (9,90=12) (10=13) (11,12=14) (13=15) (14=16) 
			 (15=17) (16=20) (else = -9).
Missing Values 	EducYrs (-9).

Rename Variables  (V162309x = IncomePost).
Missing Values	IncomePost (-9 thru -1).
*Frequencies 	 IncomePost.

****************************************************************.
***POST-ELECTON WAVE.

Frequencies     V162031x,V162034,V162034a,EarlyVtWho,V162062x.
Missing Values	V162031x,V162034,V162034a (-9 thru -1).
If		(Missing(V162034a)) V162034a = EarlyVtWho.
Frequencies	V162034a,V162062x.

Recode		V162031x (0 = 0)(1=1)(Else = 9) into PresVote/
                V162062x (1=1)(2=2)(3,4,5 = 3)(Else = 9) into VtChoice.
If              (V162034 EQ 2) PresVote = 2.
Value Labels	PresVote 0 "Nonvoter" 1 "Voted for President" 2 "Voted, but not for President".

Missing Values  V162036a,V161029b (-1,98,99).
If        	(Missing(V162036a)) V162036a = V161029b.
Frequencies	PresVote,VtChoice, V162036a.


RECODE		VtChoice (1=2)(2=3)(Else = 9) into DRVtStrength.
MISSING VALUES	PresVote, VtChoice, DRVtStrength (9).
FORMATS	PresVote, VtChoice, DRVtStrength (F1.0).
If		(DRVtStrength EQ 2 and V162066x EQ 11) DRVtStrength = 1.
If		(DRVtStrength EQ 3 and V162066x EQ 21) DRVtStrength = 4.
VALUE LABELS	PresVote 1 "Voted"/
		VtChoice 1 "Clinton" 2  "Trump" 3 "Someone else"/
		DRVtStrength 1 "Strong Clinton" 4 "Strong Trump".
VARIABLE LABELS	PresVote "POST: Did R vote for President"/
		VtChoice "2016 Vote Choice - Pre and Post Combined"/
		DRVtStrength "2016 Vote Choice Strength - Pre and Post Combined".
Frequencies	DRVtStrength.



RENAME VARIABLES (V162256 = PolInterest).
                                

MISSING VALUES PolInterest (lo thru -1).


RENAME VARIABLES  (V162255x = BOMuslim).
MISSING VALUES  BOMuslim (lo thru -1).
if		(Missing(BOMuslim) and V162255 EQ 1) BOMuslim = 4.
if		(Missing(BOMuslim) and V162255 EQ 2) BOMuslim = 7.
RECODE BOMuslim (10=1) (9=2) (8=3) (7=4) (6=5) (5=6) (4=7) (3=8) (2=9) (1=10).
VALUE LABELS BOMuslim 1"Extremely sure Obama is not a Muslim" 5"Not at all sure Obama is not a Muslim" 6"Not at all sure Obama is a Muslim" 10"Extremely sure Obama is a Muslim".







VALUE LABELS Voted16 1"Voted".

WEIGHT off.

SUBTITLE	Final Checking.
DESCRIPTIVES WeightFtF WeightWeb WeightFull.



*Demographics.
FREQUENCIES Gender Age  EducYrs Hispanic RaceEth FamIncome .

*Political Behavior/Attitudes.
FREQUENCIES PolKnow  VocabTest PolInt CampInt 
CampnBehv OthrPolBehv .

FREQUENCIES PartyID Libcon .

Subtitle        POQ paper Alt Knowledge Measure "Sophistication".


Frequencies    LibconHC, GovServHC, DefSpendHC, NHIHC, GuarJobsHC,
	        Aid2BlacksHC, EnviJobsHC, AbortHC,
 		LibconDT, GovServDT, DefSpendDT, NHIDT, GuarJobsDT,
                Aid2BlacksDT, EnviJobsDT, AbortDT.
Compute		HCCandKnow = 0.
If		(LibconHC GE 2 and LibconHC LE 3) HCCandKnow = HCCandKnow + 1.
If		(GovServHC GE 2 and GovServHC LE 3) HCCandKnow = HCCandKnow + 1.
If		(DefSpendHC GE 3 and DefSpendHC LE 4) HCCandKnow = HCCandKnow + 1.
If		(NHIHC GE 2 and NHIHC LE 3) HCCandKnow = HCCandKnow + 1.
If		(GuarJobsHC GE 2 and GuarJobsHC LE 4) HCCandKnow = HCCandKnow + 1.
If		(Aid2BlacksHC GE 2 and Aid2BlacksHC LE 3) HCCandKnow = HCCandKnow + 1.
If		(EnviJobsHC GE 2 and EnviJobsHC LE 3) HCCandKnow = HCCandKnow + 1.
If		(AbortHC GE 1 and AbortHC LE 3) HCCandKnow = HCCandKnow + 1.
Compute		DTCandKnow = 0.
If		(LibconDT GE 4 and LibconDT LE 6) DTCandKnow = DTCandKnow + 1.
If		(GovServDT GE 5 and GovServDT LE 6) DTCandKnow = DTCandKnow + 1.
If		(DefSpendDT GE 5 and DefSpendDT LE 6) DTCandKnow = DTCandKnow + 1.
If		(NHIDT GE 5 and NHIDT LE 7) DTCandKnow = DTCandKnow + 1.
If		(GuarJobsDT GE 5 and GuarJobsDT LE 7) DTCandKnow = DTCandKnow + 1.
If		(Aid2BlacksDT GE 5 and Aid2BlacksDT LE 7) DTCandKnow = DTCandKnow + 1.
If		(EnviJobsDT GE 5 and EnviJobsDT LE 7) DTCandKnow = DTCandKnow + 1.
If		(AbortDT GE 4 and AbortDT LE 6) DTCandKnow = DTCandKnow + 1.
Compute		CandKnow = HCCandKnow + DTCandKnow.
Formats		HCCandKnow,DTCandKnow (F1.0) CandKnow (F2.0).

 execute .
***Easy medium difficult and pol know. 
*refining the measure and calling it PolKnow. Taking V161138a (1) out because if you say the income gap V161137 is not larger, 
you are not asked this question and therefore "punished" twice. 

COUNT PolKnow = V161137 (1), GlobalWarming (1), 
	               V161513 (6), V161514 (1), V161515 (2), V161516 (2), 
                             V162072 (1), V162073b (1), V162074b (1), V162075b (1), V162076b (1), 
                             V162137 (2), V162191a (2), V162255 (2).  

frequencies  V161137, GlobalWarming ,
	               V161513, V161514, V161515, V161516, 
                             V162072, V162073b, V162074b, V162075b, V162076b, 
                             V162137 , V162191a, V162255.  






